1
|
|
|
/* |
2
|
|
|
* To change this license header, choose License Headers in Project Properties. |
3
|
|
|
* To change this template file, choose Tools | Templates |
4
|
|
|
* and open the template in the editor. |
5
|
|
|
*/ |
6
|
|
|
|
7
|
|
|
/* global API */ |
8
|
|
|
|
9
|
|
|
API.runtime = { |
10
|
|
|
getBackgroundPage: function() { |
11
|
|
|
if (API.promise) { |
12
|
|
|
return API.api.runtime.getBackgroundPage(); |
13
|
|
|
} |
14
|
|
|
else { |
15
|
|
|
return new C_Promise(function() { |
16
|
|
|
API.api.runtime.getBackgroundPage((function(backgroundPage){ |
17
|
|
|
this.call_then(backgroundPage); |
18
|
|
|
}).bind(this)); |
19
|
|
|
}); |
20
|
|
|
} |
21
|
|
|
}, |
22
|
|
|
openOptionsPage: function() { |
23
|
|
|
if (API.promise) { |
24
|
|
|
return API.api.runtime.openOptionsPage(); |
25
|
|
|
} |
26
|
|
|
else { |
27
|
|
|
return new C_Promise(function() { |
28
|
|
|
API.api.runtime.openOptionsPage((function() { |
29
|
|
|
this.call_then(); |
30
|
|
|
}).bind(this)); |
31
|
|
|
}); |
32
|
|
|
} |
33
|
|
|
}, |
34
|
|
|
getManifest: function() { |
35
|
|
|
return API.api.runtime.getManifest(); |
36
|
|
|
}, |
37
|
|
|
getURL: function(url) { |
38
|
|
|
return API.api.runtime.getURL(url); |
39
|
|
|
}, |
40
|
|
|
setUninstallURL: function(url) { |
41
|
|
|
if (API.promise) { |
42
|
|
|
return API.api.runtime.setUninstallURL(url); |
43
|
|
|
} |
44
|
|
|
else { |
45
|
|
|
return new C_Promise(function() { |
46
|
|
|
API.api.runtime.setUninstallURL(url, function() { |
47
|
|
|
if (typeof API.api.runtime.lastError !== "undefined") { |
48
|
|
|
this.call_error(API.api.runtime.lastError); |
49
|
|
|
return; |
50
|
|
|
} |
51
|
|
|
this.call_then(); |
52
|
|
|
}); |
53
|
|
|
}); |
54
|
|
|
} |
55
|
|
|
}, |
56
|
|
|
reload: function() { |
57
|
|
|
API.api.runtime.reload(); |
58
|
|
|
}, |
59
|
|
|
requestUpdateCheck: function() { |
60
|
|
|
if (API.promise) { |
61
|
|
|
return API.api.runtime.requestUpdateCheck(); |
62
|
|
|
} |
63
|
|
|
else { |
64
|
|
|
return new C_Promise(function() { |
65
|
|
|
API.api.runtime.requestUpdateCheck((function(status, details) { |
66
|
|
|
this.call_then(status, details); |
67
|
|
|
}).bind(this)); |
68
|
|
|
}); |
69
|
|
|
} |
70
|
|
|
}, |
71
|
|
|
restart: function() { |
72
|
|
|
if ( ! API.promise) { |
73
|
|
|
API.api.runtime.restart(); |
74
|
|
|
} |
75
|
|
|
}, |
76
|
|
|
connect: function(extensionId, connectionInfo) { |
77
|
|
|
return API.api.runtime.connect(extensionId, connectionInfo); |
78
|
|
|
}, |
79
|
|
|
connectNative: function(application) { |
80
|
|
|
return API.api.runtime.connectNative(application); |
81
|
|
|
}, |
82
|
|
|
sendMessage: function(extensionId, message, options) { |
83
|
|
|
if (API.promise) { |
84
|
|
|
return API.api.runtime.sendMessage(extensionId, message, options); |
85
|
|
|
} |
86
|
|
|
else { |
87
|
|
|
return new C_Promise(function(){ |
88
|
|
|
API.api.runtime.sendMessage(extensionId, message, options, (function(response) { |
89
|
|
|
this.call_then(response); |
90
|
|
|
}).bind(this)); |
91
|
|
|
}); |
92
|
|
|
} |
93
|
|
|
}, |
94
|
|
|
sendNativeMessage: function(application, message) { |
95
|
|
|
if (API.promise) { |
96
|
|
|
return API.api.runtime.sendNativeMessage(application, message); |
97
|
|
|
} |
98
|
|
|
else { |
99
|
|
|
return new C_Promise(function() { |
100
|
|
|
API.api.runtime.sendNativeMessage(application, message, (function(response) { |
101
|
|
|
this.call_then(response); |
102
|
|
|
}).bind(this)); |
103
|
|
|
}); |
104
|
|
|
} |
105
|
|
|
}, |
106
|
|
|
getPlatformInfo: function() { |
107
|
|
|
if (API.promise) { |
108
|
|
|
return API.api.runtime.getPlatformInfo(); |
109
|
|
|
} |
110
|
|
|
else { |
111
|
|
|
return new C_Promise(function() { |
112
|
|
|
API.api.runtime.getPlatformInfo((function(info) { |
113
|
|
|
this.call_then(info); |
114
|
|
|
}).bind(this)); |
115
|
|
|
}); |
116
|
|
|
} |
117
|
|
|
}, |
118
|
|
|
getBrowserInfo: function() { |
119
|
|
|
if (API.promise) { |
120
|
|
|
return API.api.runtime.getBrowserInfo(); |
121
|
|
|
} |
122
|
|
|
else { |
123
|
|
|
return new C_Promise(function() { |
124
|
|
|
// Not implemented in chrome |
125
|
|
|
this.call_then(null); |
126
|
|
|
}); |
127
|
|
|
} |
128
|
|
|
}, |
129
|
|
|
getPackageDirectoryEntry: function() { |
130
|
|
|
if (API.promise) { |
131
|
|
|
return API.api.runtime.getPackageDirectoryEntry(); |
132
|
|
|
} |
133
|
|
|
else { |
134
|
|
|
return new C_Promise(function() { |
135
|
|
|
API.api.runtime.getPackageDirectoryEntry((function(directoryEntry) { |
136
|
|
|
this.call_then(directoryEntry); |
137
|
|
|
}).bind(this)); |
138
|
|
|
}); |
139
|
|
|
} |
140
|
|
|
}, |
141
|
|
|
|
142
|
|
|
id: API.api.runtime.id, |
143
|
|
|
|
144
|
|
|
/** |
145
|
|
|
* Events from now on! |
146
|
|
|
*/ |
147
|
|
|
onStartup: API.api.runtime.onStartup, |
148
|
|
|
onInstalled: API.api.runtime.onInstalled, |
149
|
|
|
onSuspend: API.api.runtime.onSuspend, |
150
|
|
|
onSuspendCanceled: API.api.runtime.onSuspendCanceled, |
151
|
|
|
onUpdateAvailable: API.api.runtime.onUpdateAvailable, |
152
|
|
|
onBrowserUpdateAvailable: API.api.runtime.onBrowserUpdateAvailable, |
153
|
|
|
onConnect: API.api.runtime.onConnect, |
154
|
|
|
onConnectExternal: API.api.runtime.onConnectExternal, |
155
|
|
|
onMessage: API.api.runtime.onMessage, |
156
|
|
|
onMessageExternal: API.api.runtime.onMessageExternal, |
157
|
|
|
onRestartRequired: API.api.runtime.onRestartRequired |
158
|
|
|
}; |
159
|
|
|
|